﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Diagnostics;
using System.ComponentModel;
using WPFExcelReport.Helpers;
using System.Windows.Input;
namespace WPFExcelReport
{
    public partial class TBSGROE
    {
        public TBSGROE()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VBSGROE();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            dwData = TBMain.NewRow();
            dwData["BSGMANDANT"] = app.Mandant; 
            dwData["BSGART"] = " AND BSGART LIKE '%" + ART.Trim()+"%'";
            SResult = TMV.QBSGROE06(dwData);
            MergeData(SResult, false);
            base.QueryCommand(sender, e);
        }
        public override void LOADBYAUF()
        {
            if (!IsSaved)
                return;
            if (ORDERNUM != KEY)
                return;
            dwData = TBMain.NewRow();
            dwData["BSGMANDANT"] = app.Mandant;
            dwData["BSGART"] = " AND BSGART = '" + ORDERNUM.Substring(0,20) + "'  ";
            dwData["BSGMTYP"] = " AND BSGMTYP = '" + ORDERNUM.Substring(20, 6) + "'  ";
            
            SResult = TMV.QBSGROE06(dwData);
            foreach(DataRow row in SResult.Tables[0].Rows)
            {
                dwMaster.ItemArray = row.ItemArray;
            }
            base.LOADBYAUF();
        }
    }
}
